package hutech.ksv.entity;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

public class NhaTroDataModel extends ListDataModel<ThongTinNhaTroEntity> implements
		SelectableDataModel<ThongTinNhaTroEntity> {
	
	public NhaTroDataModel() {
		
	}
	
	public NhaTroDataModel(List<ThongTinNhaTroEntity> data) {
		super(data);
	}

	@Override
	public ThongTinNhaTroEntity getRowData(String rowKey) {
		List<ThongTinNhaTroEntity> danhSachNhaTro = (List<ThongTinNhaTroEntity>) getWrappedData();
		
		for(ThongTinNhaTroEntity c : danhSachNhaTro) {
			if(c.getMaNT() == Integer.parseInt(rowKey)) {
				return c;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(ThongTinNhaTroEntity thongTinNhaTroEntity) {
		return thongTinNhaTroEntity.getMaNT();
	}

}
